// pages/cart/cart.js
import {http} from "../../utils/http"
Page({

  /**
   * 页面的初始数据
   */
  data: {

  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad() {
    this.getlist()
    this.gettu()
  },
  async getlist(){
      let {data:res} = await http({
        url:"https://api.it120.cc/small4/shop/goods/category/all",
        method:"POST"
      }).catch(err=>err)
      // console.log(res.data);
      let list =res.data
      this.setData({
        list
      })
  },
  async gettu(){
      let {data:res} = await http({
        url:"https://api.it120.cc/small4/shop/goods/category/all",
        method:"POST"
      }).catch(err=>err)
      // console.log(res.data);
      let tu =res.data
      this.setData({
        tu
      })
  },
  // Godetail(e){
  //   console.log(e);
  //   let id = e.currentTarget.dataset.id
  //   wx.navigateTo({
  //     url: '../../pages/detail/detail'+id,
  //   })
  // },
  myClick(e){
    // console.log(e);
    let type = e.currentTarget.dataset.type
    if(!type){
      this.gettu()
    }else{
      let tu = this.data.list.filter(item=>{
        return item.type.includes(type)
      })
      // console.log(tu,'tu');
      this.setData({
        tu
      })
    }
  }

 
})